Python 3.11.0 | packaged by conda-forge | (main, Jan 16 2023, 14:12:30) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.10.0 -- An enhanced Interactive Python. Type '?' for help.
import os
import sys
from functools import partial
sys.path.append(os.path.join(os.getcwd(), '..')) #adds directory below as valid path
from datetime import datetime, timedelta
dateformat = "%H-%M-%S"
from collections import deque
import traceback
from multiprocessing import Pool
from tqdm import tqdm
import scipy.constants as spc
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
plt.rcParams['axes.grid'] = True
plt.rcParams['grid.linestyle'] = '--'
from MT_class_PID_new import MTdataHost
from global_folder.myplotsty import *
PUMP_FREQUENCY = 384228.6
REPUMP_FREQUENCY = 384228.6 + 6.56
SAMPLE_RATE = 2000
FREQVSVOLT = 220.0
FREQVSCURR = 1.16
# TODO: find a better place for this
EXP_FOLDER =r'C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements'
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun10')
WDATA_FOLDER =os.path.join(MEASURE_FOLDER, 'testPArun10.csv')
# TODO: maybe make a run analysis class out of this?
def dump():
plot_results(df, max_freq= 384219., fmt='o', mfc='red', save_folder=MEASURE_FOLDER)
plt.savefig(os.path.join(MEASURE_FOLDER, 'ratio_vs_freq.png'))
collect_plots(MEASURE_FOLDER, os.path.join(MEASURE_FOLDER, 'collected_plots'), 'deloadPhase.png')
#-----------------------
# SINGLE RUN
#-----------------------
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
freqs = plot_results(df, 384201., save_folder=MEASURE_FOLDER)
data = df.dropna()[:100]
freqs = ((384201-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.1, save_folder=MEASURE_FOLDER,
mfc='red', color='black',
title='Trap Depth = 1.99 K')
#-----------------------
# MULTIPLE RUN COMPARISON
#-----------------------
folders = [os.path.join(EXP_FOLDER, path ) for path in ['testPARun11', 'testPARun12', 'testPARun13', 'testPARun14']]
dfs = [get_data_frame(measure_folder, cache_all=True) for measure_folder in folders]
colors = ['red', 'dodgerblue', 'green', 'grey']
max_freqs = [384178.881, 384178.593,384179.068, 384184.731]
#max_freqs=[384178.599, 384179.091, 384184.733]
zipped_data = list(zip(dfs, max_freqs))
fig, ax = plt.subplots()
for i, (df, max_freq) in enumerate(zipped_data[:3]):
data = df.dropna()
freqs = ((max_freq-PUMP_FREQUENCY)-(data['tempV']-data['tempV'].min())*FREQVSVOLT- (data['currV']-data['currV'].min())*FREQVSCURR)
color = colors[i]
ax=plot_spline_fit(ax, x=freqs, y=data['ratio'], scolor=color, mfc=color,color=color, s=0.02, ms=5)
#-----------------------
# PARSING WAVEMETER DATA
#-----------------------
FREQVSVOLT = 225.0
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun14')
WDATA_FOLDER =os.path.join(MEASURE_FOLDER, 'testPArun14.csv')
freq_data, max_freq, min_freq = add_wavemeter_data('', WDATA_FOLDER)
data = freq_data[:]
levels = staircase_fit(data)
data = get_data_frame(MEASURE_FOLDER)
data.dropna(inplace=True)
freqs = ((max_freq)-(data['tempV']-data['tempV'].min())*FREQVSVOLT- (data['currV']-data['currV'].min())*FREQVSCURR)
plt.plot(freqs)
# -----------------------
# RELATIVE SCATTERING RATE
# -----------------------
run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\relScatRate\22-09-38"
filename = os.path.join(run_path, 'data.csv')
bkfilename = os.path.join(run_path, 'data_oldPD.csv')
settingsname = os.path.join(run_path, 'Settings.txt')
dh1 = MTdataHost(SAMPLE_RATE)
dh1.loadCATdata(fileName=filename, settingsName=settingsname)
dh1.tBaseline = 1
dh1.tLoad = 2
dh1.timeLoad = 60
dh1.tReload = dh1.tLoad + dh1.timeLoad
dh1.timeReload = 1
dh1.tCATbackground = dh1.tReload + dh1.timeReload
#dh1.CATbackgroundData(bkfilename)
dh1.setAllCAT(0.002)
print(dh1.motSS/(dh1.reloadVolt+dh1.baseVolt - (dh1.CATbackgroundVolt+dh1.noLightBackground)))
plt.scatter(dh1.time, dh1.voltage, s=0.1)
plt.plot(dh1.reloadTime,dh1.reloadFitVoltage, c='orange')
plt.plot(dh1.loadingTime,dh1.motFit, c='red')
plt.plot(dh1.baseTime,dh1.baseVoltage, c='yellow')
plt.plot(dh1.CATbackgroundTime,dh1.CATbackgroundVoltage, c='pink')
def save_fit_results(run_path, plot=False):
filename = os.path.join(run_path, 'data.csv')
bkfilename = os.path.join(run_path, 'data_oldPD.csv')
settingsname = os.path.join(run_path, 'Settings.txt')
dataHost = MTdataHost(SAMPLE_RATE)
dataHost.loadCATdata(fileName=filename, settingsName=settingsname)
dataHost.CATbackgroundData(bkfilename)
dataHost.setAllCAT(0.002)
resultDict = dataHost.getResults(run_path, store=True)
if plot:
dataHost.storeFits(run_path, combined=True, separate=True)
return resultDict, dataHost.settings
def get_timestamp(run_path):
timestamp = datetime.strptime(os.path.split(run_path)[-1].split('_')[0], dateformat)
return timestamp
def extract_fit(run_path, plot=True, cache_failed=True, cache_all=True):
"""Gather relevant data from each measurement run
Args:
run_path : absolute path to the run directory
plot (bool, optional): plot fits. Defaults to True.
cache_failed (bool, optional): Cache failed fits. If false, refit. Doesn't refit non-failed fits. Defaults to True.
cache_all (bool, optional): If false, ignore any cached fit_results. Defaults to True.
Returns:
a 3-tuple (fit_results, settings, timestamp)
"""
fit_results, settings, timestamp = {}, {}, None
if not os.path.isdir(run_path):
return fit_results, settings, timestamp # directory is not a run directory
try:
timestamp = get_timestamp(run_path)
# TODO: specify which error to catch
except Exception as e:
print("Error extracting timestamp from: ", run_path)
print(traceback.format_exc())
MAT_fit_cache_path = os.path.join(run_path, 'resultDict.txt')
if not os.path.exists(MAT_fit_cache_path) or not cache_all:
try:
fit_results, settings = save_fit_results(run_path, plot=plot)
except Exception as e:
print(traceback.format_exc())
print("Fitting ERROR at ", os.path.basename(run_path), '\n')
with open(MAT_fit_cache_path, 'w') as f:
f.write(str('MAT fit failed'))
else:
print("Accessing cached results from :", os.path.basename(run_path))
fit_results = open(MAT_fit_cache_path, 'r').read()
if fit_results == 'MAT fit failed':
if not cache_failed:
# fit regardless of cached result
try:
fit_results = save_fit_results(run_path, plot=plot)
except Exception as e:
print(traceback.format_exc())
print("Fitting ERROR at ", os.path.basename(run_path), '\n')
with open(MAT_fit_cache_path, 'w') as f:
f.write(str('MAT fit failed'))
else:
print("Failed fit at :", os.path.basename(run_path))
fit_results = {}
else:
fit_results = eval(open(MAT_fit_cache_path, 'r').read())
settingsname = os.path.join(run_path, 'Settings.txt')
settings = eval(open(settingsname, 'r').read())
return fit_results, settings, timestamp
def get_row(run_path, **kwargs):
fit_results, settings, timestamp = extract_fit(run_path, **kwargs)
row = {**fit_results, **settings, **{'timestamp':timestamp}}
return row
def get_data_frame(data_dir, parallel=True, in_process_run=False, **kwargs):
run_path_arr = []
rows = []
for relative_path in os.listdir(data_dir):
run_path_arr.append(os.path.join(data_dir, relative_path))
if in_process_run:
run_path_arr.pop()
run_path_arr = sorted(run_path_arr)
if parallel:
with Pool(4) as p:
rows = list(tqdm(p.imap(partial(get_row, **kwargs), run_path_arr), total=len(run_path_arr)))
else:
for run_path in tqdm(run_path_arr):
rows.append(get_row(run_path, **kwargs))
return pd.DataFrame.from_dict(rows)
def add_wavemeter_data(df, wmeter_csv_path, window_size=100, num_rows=50):
"""Extract unique frequnecy values from wavemeter data
Returns:
unique_levels (list): unique frequency values in wavemeter data
"""
# TODO: modify dataframe in place with frequency data
wdata = pd.read_csv(wmeter_csv_path, skiprows=2)
wdata.dropna(inplace=True)
freq_data = np.array(wdata.iloc[:, 0])
try:
freq_data = np.array([float(item) for item in freq_data if item.replace('.','').isdigit()])
except Exception as e:
pass
max_freq = freq_data.max()
min_freq = freq_data.min()
return freq_data, max_freq, min_freq
def plot_results(dfs, max_freq, min_freq=0.0, mfc='red', fmt='o', ms=5, save_folder=False, xscale=1.0, yscale=1.0, **kwargs):
FREQVSVOLT = 214.0
FREQVSCURR = 1.14
if not type(dfs) == list:
freqs = ((max_freq-PUMP_FREQUENCY)-(dfs.dropna()['tempV']-dfs.dropna()['tempV'].min())*FREQVSVOLT- (dfs.dropna()['currV']-dfs.dropna()['currV'].min())*FREQVSCURR)*xscale
dfs=[dfs]
plt.gcf().set_dpi(300)
for df in dfs:
df = df.dropna()
plt.errorbar(freqs,
df['ratio']*yscale,
yerr=df['ratioErr'],
fmt=fmt, mfc=mfc, color='black', ms=ms, **kwargs)
plt.ylabel(r'$\mathbf{\frac{V_{ss, cat}}{V_{ss}}} $ ')
plt.xlabel(r'$\Delta $ (GHz)', fontdict={'weight':'bold'})
if save_folder:
plt.savefig(os.path.join(save_folder, 'ratio_vs_freq.png'))
return freqs
#return plt.gca(), plt.gcf()
#plt.show()
def plot_spline_fit(ax, x, y, s=1, yerr=None, scolor='black',figsize=(12,5), save_folder=None, title='',alpha=0.5,dpi=200,**kwargs):
from scipy.interpolate import splev, splrep
xnew = np.linspace(min(x), max(x), 3*len(x) )
x = sorted(x)
y = [b for a,b in sorted(zip(x,y), key=lambda pair: pair[0])]
spl = splrep(x, y, s=s)
ynew = splev(xnew, spl)
plt.gcf().set_dpi(dpi)
plt.gcf().set_size_inches(figsize)
if yerr is not None:
ax.errorbar(x, y, yerr=yerr, fmt='o', **kwargs)
else:
ax.plot(x,y, 'o', **kwargs)
ax.plot(xnew, ynew, '-', color=scolor, alpha=alpha)
ax.set_ylabel(r'$\mathbf{\frac{V_{ss, cat}}{V_{ss}}} $ ', labeldict)
ax.set_xlabel(r'$\Delta $ (GHz)', **labeldict)
ax.set_title(title, **titledict)
if save_folder:
plt.savefig(os.path.join(save_folder, 'spline_ratio_vs_freq.png'))
return ax
def plot_polyfit(x_data, y_data, spline_degree):
coefficients = np.polyfit(x_data, y_data, spline_degree)
x_interp = np.linspace(min(x_data), max(x_data), 100)
y_interp = np.polyval(coefficients, x_interp)
plt.scatter(x_data, y_data, label='Original Data')
plt.plot(x_interp, y_interp, label='Polynomial Interpolation (Degree={})'.format(spline_degree))
def collect_plots(source, destination, plot_name):
print(f'Collecting plots from {os.path.basename(source)}')
import shutil
os.makedirs(destination, exist_ok=True)
plot_files = []
for root, dirs, files in os.walk(source):
for file in files:
if file == plot_name:
plot_files.append(os.path.join(root, file))
for i, plot_file in enumerate(plot_files, start=0):
new_filename = f'{i}{plot_name}'
destination_path = os.path.join(destination, new_filename)
shutil.copy(plot_file, destination_path)
def create_GIF(images_folder, image_name):
import imageio
with imageio.get_writer(os.path.join(images_folder, f'{image_name}movie.gif'), mode='I', duration=0.5) as writer:
for filename in os.listdir(images_folder):
if image_name in filename:
image = imageio.imread(os.path.join(images_folder, filename))
writer.append_data(image)
def staircase_fit(data):
def moving_average(arr, window_size):
weights = np.ones(window_size) / window_size
return np.convolve(arr, weights, mode='valid')
convdata1 = moving_average(data, 2)
convdata2 = moving_average(data[10:], 2 )
final = convdata1[:len(convdata2)]-convdata2
# plt.plot(data)
# plt.plot(convdata1)
# plt.plot(convdata2)
# plt.show()
# plt.plot(final)
from scipy.signal import find_peaks
x= final
peaks, _ = find_peaks(x, height=0.1, distance=100)
peaks = np.insert(peaks, 0, 0)
plt.plot(x)
plt.plot(peaks, x[peaks], "x")
plt.plot(np.zeros_like(x), "--", color="gray")
plt.show()
levels = []
plot_arr = []
for i, peak in enumerate(peaks):
if i < len(peaks) - 1:
temp = data[ peaks[i]:peaks[i+1] ]
plot_arr.extend( np.ones_like(temp)*np.mean(temp))
levels.append(np.mean(temp))
plt.plot(data)
plt.plot(np.ravel((plot_arr)))
plt.show()
plt.close()
plt.plot(np.array(levels)[np.where(abs(np.diff(levels))>0.05)[0]], 'o', ms=1)
return levels
if __name__ == '__main__':
run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\testPArun9\16-53-10"
filename = os.path.join(run_path, 'data.csv')
bkfilename = os.path.join(run_path, 'data_oldPD.csv')
settingsname = os.path.join(run_path, 'Settings.txt')
dh1 = MTdataHost(SAMPLE_RATE)
dh1.loadCATdata(fileName=filename, settingsName=settingsname)
#dh1.CATbackgroundData(bkfilename)
dh1.setAllCAT(0.002)
# ---------------------
# Look at Loading rate
# ---------------------
# run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\testPArun9\16-38-18"
# filename = os.path.join(run_path, 'data.csv')
# bkfilename = os.path.join(run_path, 'data_oldPD.csv')
# settingsname = os.path.join(run_path, 'Settings.txt')
# dataHost1 = MTdataHost(SAMPLE_RATE)
# dataHost1.loadCATdata(fileName=filename, settingsName=settingsname)
# #dataHost.CATbackgroundData(bkfilename)
# dataHost1.setAllCAT(0.002)
# run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\testPArun10\21-05-29"
# filename = os.path.join(run_path, 'data.csv')
# bkfilename = os.path.join(run_path, 'data_oldPD.csv')
# settingsname = os.path.join(run_path, 'Settings.txt')
# dataHost2 = MTdataHost(SAMPLE_RATE)
# dataHost2.loadCATdata(fileName=filename, settingsName=settingsname)
# #dataHost.CATbackgroundData(bkfilename)
# dataHost2.setAllCAT(0.002)
File loaded: RFmin = 49 MHz, t_mt = 1.050 s.
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun4')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
data = df.dropna()[:100]
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.1,
scolor='dodgerblue', color='dodgerblue'
)
100%|██████████| 140/140 [00:01<00:00, 71.13it/s]
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun4')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
data = df.dropna()
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.1,
scolor='dodgerblue', color='dodgerblue'
)
100%|██████████| 140/140 [00:02<00:00, 61.53it/s]
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun4')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
data = df.dropna()
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.1,
scolor='dodgerblue', color='dodgerblue'
figsize=(20,5))
Cell In[4], line 13 scolor='dodgerblue', color='dodgerblue' ^ SyntaxError: invalid syntax. Perhaps you forgot a comma?
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun4')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
data = df.dropna()
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.1,
scolor='dodgerblue', color='dodgerblue'
,fig_size=(15,5))
100%|██████████| 140/140 [00:02<00:00, 64.10it/s]
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[5], line 11 9 freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR) 10 fig, ax = plt.subplots() ---> 11 plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'], 12 s=0.1, 13 scolor='dodgerblue', color='dodgerblue' 14 ,fig_size=(15,5)) Cell In[1], line 308, in plot_spline_fit(ax, x, y, s, yerr, scolor, figsize, save_folder, title, alpha, dpi, **kwargs) 305 plt.gcf().set_size_inches(figsize) 307 if yerr is not None: --> 308 ax.errorbar(x, y, yerr=yerr, fmt='o', **kwargs) 309 else: 310 ax.plot(x,y, 'o', **kwargs) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\__init__.py:1442, in _preprocess_data.<locals>.inner(ax, data, *args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/__init__.py?line=1438'>1439</a> @functools.wraps(func) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/__init__.py?line=1439'>1440</a> def inner(ax, *args, data=None, **kwargs): <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/__init__.py?line=1440'>1441</a> if data is None: -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/__init__.py?line=1441'>1442</a> return func(ax, *map(sanitize_sequence, args), **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/__init__.py?line=1443'>1444</a> bound = new_sig.bind(ax, *args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/__init__.py?line=1444'>1445</a> auto_label = (bound.arguments.get(label_namer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/__init__.py?line=1445'>1446</a> or bound.kwargs.get(label_namer)) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_axes.py:3548, in Axes.errorbar(self, x, y, yerr, xerr, fmt, ecolor, elinewidth, capsize, barsabove, lolims, uplims, xlolims, xuplims, errorevery, capthick, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=3541'>3542</a> kwargs['label'] = '_nolegend_' <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=3543'>3544</a> # Create the main line and determine overall kwargs for child artists. <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=3544'>3545</a> # We avoid calling self.plot() directly, or self._get_lines(), because <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=3545'>3546</a> # that would call self._process_unit_info again, and do other indirect <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=3546'>3547</a> # data processing. -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=3547'>3548</a> (data_line, base_style), = self._get_lines._plot_args( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=3548'>3549</a> (x, y) if fmt == '' else (x, y, fmt), kwargs, return_kwargs=True) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=3550'>3551</a> # Do this after creating `data_line` to avoid modifying `base_style`. <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=3551'>3552</a> if barsabove: File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_base.py:542, in _process_plot_var_args._plot_args(self, tup, kwargs, return_kwargs, ambiguous_fmt_datakey) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=536'>537</a> result = (make_artist(x[:, j % ncx], y[:, j % ncy], kw, <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=537'>538</a> {**kwargs, 'label': label}) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=538'>539</a> for j, label in enumerate(labels)) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=540'>541</a> if return_kwargs: --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=541'>542</a> return list(result) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=542'>543</a> else: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=543'>544</a> return [l[0] for l in result] File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_base.py:537, in <genexpr>(.0) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=533'>534</a> else: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=534'>535</a> labels = [label] * n_datasets --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=536'>537</a> result = (make_artist(x[:, j % ncx], y[:, j % ncy], kw, <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=537'>538</a> {**kwargs, 'label': label}) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=538'>539</a> for j, label in enumerate(labels)) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=540'>541</a> if return_kwargs: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=541'>542</a> return list(result) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_base.py:351, in _process_plot_var_args._makeline(self, x, y, kw, kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=348'>349</a> default_dict = self._getdefaults(set(), kw) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=349'>350</a> self._setdefaults(default_dict, kw) --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=350'>351</a> seg = mlines.Line2D(x, y, **kw) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=351'>352</a> return seg, kw File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\_api\deprecation.py:454, in make_keyword_only.<locals>.wrapper(*args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=447'>448</a> if len(args) > name_idx: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=448'>449</a> warn_deprecated( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=449'>450</a> since, message="Passing the %(name)s %(obj_type)s " <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=450'>451</a> "positionally is deprecated since Matplotlib %(since)s; the " <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=451'>452</a> "parameter will become keyword-only %(removal)s.", <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=452'>453</a> name=name, obj_type=f"parameter of {func.__name__}()") --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=453'>454</a> return func(*args, **kwargs) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\lines.py:393, in Line2D.__init__(self, xdata, ydata, linewidth, linestyle, color, gapcolor, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor, markerfacecoloralt, fillstyle, antialiased, dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, pickradius, drawstyle, markevery, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=388'>389</a> self.set_markeredgewidth(markeredgewidth) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=390'>391</a> # update kwargs before updating data to give the caller a <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=391'>392</a> # chance to init axes (and hence unit support) --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=392'>393</a> self._internal_update(kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=393'>394</a> self._pickradius = pickradius <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=394'>395</a> self.ind_offset = 0 File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:1223, in Artist._internal_update(self, kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1215'>1216</a> def _internal_update(self, kwargs): <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1216'>1217</a> """ <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1217'>1218</a> Update artist properties without prenormalizing them, but generating <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1218'>1219</a> errors as if calling `set`. <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1219'>1220</a> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1220'>1221</a> The lack of prenormalization is to maintain backcompatibility. <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1221'>1222</a> """ -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1222'>1223</a> return self._update_props( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1223'>1224</a> kwargs, "{cls.__name__}.set() got an unexpected keyword argument " <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1224'>1225</a> "{prop_name!r}") File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:1197, in Artist._update_props(self, props, errfmt) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1194'>1195</a> func = getattr(self, f"set_{k}", None) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1195'>1196</a> if not callable(func): -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1196'>1197</a> raise AttributeError( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1197'>1198</a> errfmt.format(cls=type(self), prop_name=k)) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1198'>1199</a> ret.append(func(v)) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1199'>1200</a> if ret: AttributeError: Line2D.set() got an unexpected keyword argument 'fig_size'
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun4')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
data = df.dropna()
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.1,
scolor='dodgerblue', color='dodgerblue'
,figsize=(15,5))
100%|██████████| 140/140 [00:02<00:00, 61.81it/s]
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.05,
scolor='dodgerblue', color='dodgerblue'
,figsize=(15,5))
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.03,
scolor='dodgerblue', color='dodgerblue'
,figsize=(15,5))
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.0,
scolor='dodgerblue', color='dodgerblue'
,figsize=(15,5))
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.01,
scolor='dodgerblue', color='dodgerblue'
,figsize=(15,5))
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.01,
scolor='dodgerblue', color='dodgerblue'
,figsize=(4,5))
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.00,
scolor='dodgerblue', color='dodgerblue'
,figsize=(4,5))
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>
freqs = ((384183.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'],
s=0.00,
scolor='dodgerblue', color='dodgerblue'
,figsize=(4,5))
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
data = df.dropna()
freqs = ((384394.4-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.1,
scolor='dodgerblue', color='dodgerblue'
)
100%|██████████| 53/53 [00:03<00:00, 16.52it/s]
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
plot_results(df, 384394.4 save_folder=MEASURE_FOLDER)
Cell In[15], line 8 plot_results(df, 384394.4 save_folder=MEASURE_FOLDER) ^ SyntaxError: invalid syntax. Perhaps you forgot a comma?
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
plot_results(df, 384394.4, save_folder=MEASURE_FOLDER)
100%|██████████| 53/53 [00:01<00:00, 31.48it/s]
1 165.800 2 162.804 3 159.808 4 156.812 5 153.816 6 150.820 7 147.824 8 144.828 9 141.832 10 138.836 11 135.840 12 132.844 13 129.848 14 126.852 15 123.856 16 120.860 17 117.864 18 114.868 19 111.872 20 108.876 21 105.880 22 102.884 23 99.888 24 96.892 25 93.896 26 90.900 27 87.904 28 84.908 29 81.912 30 78.916 31 75.920 32 72.924 33 69.928 34 66.932 35 63.936 36 60.940 37 57.944 38 54.948 39 51.952 40 48.956 41 45.960 42 42.964 43 39.968 44 36.972 45 33.976 46 30.980 47 27.984 48 24.988 49 21.992 50 18.996 dtype: float64
import os
import sys
from functools import partial
sys.path.append(os.path.join(os.getcwd(), '..')) #adds directory below as valid path
from datetime import datetime, timedelta
dateformat = "%H-%M-%S"
from collections import deque
import traceback
from multiprocessing import Pool
from tqdm import tqdm
import scipy.constants as spc
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
plt.rcParams['axes.grid'] = True
plt.rcParams['grid.linestyle'] = '--'
from MT_class_PID_new import MTdataHost
from global_folder.myplotsty import *
PUMP_FREQUENCY = 384228.6
REPUMP_FREQUENCY = 384228.6 + 6.56
SAMPLE_RATE = 2000
FREQVSVOLT = 220.0
FREQVSCURR = 1.16
# TODO: find a better place for this
EXP_FOLDER =r'C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements'
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun10')
WDATA_FOLDER =os.path.join(MEASURE_FOLDER, 'testPArun10.csv')
# TODO: maybe make a run analysis class out of this?
def dump():
plot_results(df, max_freq= 384219., fmt='o', mfc='red', save_folder=MEASURE_FOLDER)
plt.savefig(os.path.join(MEASURE_FOLDER, 'ratio_vs_freq.png'))
collect_plots(MEASURE_FOLDER, os.path.join(MEASURE_FOLDER, 'collected_plots'), 'deloadPhase.png')
#-----------------------
# SINGLE RUN
#-----------------------
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
#freqs = plot_results(df, 384201., save_folder=MEASURE_FOLDER)
data = df.dropna()
freqs = ((384201-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.1, save_folder=MEASURE_FOLDER,
mfc='red', color='black',
title='Trap Depth = 1.99 K')
#-----------------------
# MULTIPLE RUN COMPARISON
#-----------------------
folders = [os.path.join(EXP_FOLDER, path ) for path in ['testPARun11', 'testPARun12', 'testPARun13', 'testPARun14']]
dfs = [get_data_frame(measure_folder, cache_all=True) for measure_folder in folders]
colors = ['red', 'dodgerblue', 'green', 'grey']
max_freqs = [384178.881, 384178.593,384179.068, 384184.731]
#max_freqs=[384178.599, 384179.091, 384184.733]
zipped_data = list(zip(dfs, max_freqs))
fig, ax = plt.subplots()
for i, (df, max_freq) in enumerate(zipped_data[:3]):
data = df.dropna()
freqs = ((max_freq-PUMP_FREQUENCY)-(data['tempV']-data['tempV'].min())*FREQVSVOLT- (data['currV']-data['currV'].min())*FREQVSCURR)
color = colors[i]
ax=plot_spline_fit(ax, x=freqs, y=data['ratio'], scolor=color, mfc=color,color=color, s=0.02, ms=5)
#-----------------------
# PARSING WAVEMETER DATA
#-----------------------
FREQVSVOLT = 225.0
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun14')
WDATA_FOLDER =os.path.join(MEASURE_FOLDER, 'testPArun14.csv')
freq_data, max_freq, min_freq = add_wavemeter_data('', WDATA_FOLDER)
data = freq_data[:]
levels = staircase_fit(data)
data = get_data_frame(MEASURE_FOLDER)
data.dropna(inplace=True)
freqs = ((max_freq)-(data['tempV']-data['tempV'].min())*FREQVSVOLT- (data['currV']-data['currV'].min())*FREQVSCURR)
plt.plot(freqs)
# -----------------------
# RELATIVE SCATTERING RATE
# -----------------------
run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\relScatRate\22-09-38"
filename = os.path.join(run_path, 'data.csv')
bkfilename = os.path.join(run_path, 'data_oldPD.csv')
settingsname = os.path.join(run_path, 'Settings.txt')
dh1 = MTdataHost(SAMPLE_RATE)
dh1.loadCATdata(fileName=filename, settingsName=settingsname)
dh1.tBaseline = 1
dh1.tLoad = 2
dh1.timeLoad = 60
dh1.tReload = dh1.tLoad + dh1.timeLoad
dh1.timeReload = 1
dh1.tCATbackground = dh1.tReload + dh1.timeReload
#dh1.CATbackgroundData(bkfilename)
dh1.setAllCAT(0.002)
print(dh1.motSS/(dh1.reloadVolt+dh1.baseVolt - (dh1.CATbackgroundVolt+dh1.noLightBackground)))
plt.scatter(dh1.time, dh1.voltage, s=0.1)
plt.plot(dh1.reloadTime,dh1.reloadFitVoltage, c='orange')
plt.plot(dh1.loadingTime,dh1.motFit, c='red')
plt.plot(dh1.baseTime,dh1.baseVoltage, c='yellow')
plt.plot(dh1.CATbackgroundTime,dh1.CATbackgroundVoltage, c='pink')
def save_fit_results(run_path, plot=False):
filename = os.path.join(run_path, 'data.csv')
bkfilename = os.path.join(run_path, 'data_oldPD.csv')
settingsname = os.path.join(run_path, 'Settings.txt')
dataHost = MTdataHost(SAMPLE_RATE)
dataHost.loadCATdata(fileName=filename, settingsName=settingsname)
dataHost.CATbackgroundData(bkfilename)
dataHost.setAllCAT(0.002)
resultDict = dataHost.getResults(run_path, store=True)
if plot:
dataHost.storeFits(run_path, combined=True, separate=True)
return resultDict, dataHost.settings
def get_timestamp(run_path):
timestamp = datetime.strptime(os.path.split(run_path)[-1].split('_')[0], dateformat)
return timestamp
def extract_fit(run_path, plot=True, cache_failed=True, cache_all=True):
"""Gather relevant data from each measurement run
Args:
run_path : absolute path to the run directory
plot (bool, optional): plot fits. Defaults to True.
cache_failed (bool, optional): Cache failed fits. If false, refit. Doesn't refit non-failed fits. Defaults to True.
cache_all (bool, optional): If false, ignore any cached fit_results. Defaults to True.
Returns:
a 3-tuple (fit_results, settings, timestamp)
"""
fit_results, settings, timestamp = {}, {}, None
if not os.path.isdir(run_path):
return fit_results, settings, timestamp # directory is not a run directory
try:
timestamp = get_timestamp(run_path)
# TODO: specify which error to catch
except Exception as e:
print("Error extracting timestamp from: ", run_path)
print(traceback.format_exc())
MAT_fit_cache_path = os.path.join(run_path, 'resultDict.txt')
if not os.path.exists(MAT_fit_cache_path) or not cache_all:
try:
fit_results, settings = save_fit_results(run_path, plot=plot)
except Exception as e:
print(traceback.format_exc())
print("Fitting ERROR at ", os.path.basename(run_path), '\n')
with open(MAT_fit_cache_path, 'w') as f:
f.write(str('MAT fit failed'))
else:
print("Accessing cached results from :", os.path.basename(run_path))
fit_results = open(MAT_fit_cache_path, 'r').read()
if fit_results == 'MAT fit failed':
if not cache_failed:
# fit regardless of cached result
try:
fit_results = save_fit_results(run_path, plot=plot)
except Exception as e:
print(traceback.format_exc())
print("Fitting ERROR at ", os.path.basename(run_path), '\n')
with open(MAT_fit_cache_path, 'w') as f:
f.write(str('MAT fit failed'))
else:
print("Failed fit at :", os.path.basename(run_path))
fit_results = {}
else:
fit_results = eval(open(MAT_fit_cache_path, 'r').read())
settingsname = os.path.join(run_path, 'Settings.txt')
settings = eval(open(settingsname, 'r').read())
return fit_results, settings, timestamp
def get_row(run_path, **kwargs):
fit_results, settings, timestamp = extract_fit(run_path, **kwargs)
row = {**fit_results, **settings, **{'timestamp':timestamp}}
return row
def get_data_frame(data_dir, parallel=True, in_process_run=False, **kwargs):
run_path_arr = []
rows = []
for relative_path in os.listdir(data_dir):
run_path_arr.append(os.path.join(data_dir, relative_path))
if in_process_run:
run_path_arr.pop()
run_path_arr = sorted(run_path_arr)
if parallel:
with Pool(4) as p:
rows = list(tqdm(p.imap(partial(get_row, **kwargs), run_path_arr), total=len(run_path_arr)))
else:
for run_path in tqdm(run_path_arr):
rows.append(get_row(run_path, **kwargs))
return pd.DataFrame.from_dict(rows)
def add_wavemeter_data(df, wmeter_csv_path, window_size=100, num_rows=50):
"""Extract unique frequnecy values from wavemeter data
Returns:
unique_levels (list): unique frequency values in wavemeter data
"""
# TODO: modify dataframe in place with frequency data
wdata = pd.read_csv(wmeter_csv_path, skiprows=2)
wdata.dropna(inplace=True)
freq_data = np.array(wdata.iloc[:, 0])
try:
freq_data = np.array([float(item) for item in freq_data if item.replace('.','').isdigit()])
except Exception as e:
pass
max_freq = freq_data.max()
min_freq = freq_data.min()
return freq_data, max_freq, min_freq
def plot_results(ax, dfs, max_freq, min_freq=0.0, mfc='red', fmt='o', ms=5, save_folder=False, xscale=1.0, yscale=1.0, **kwargs):
FREQVSVOLT = 214.0
FREQVSCURR = 1.14
if not type(dfs) == list:
freqs = ((max_freq-PUMP_FREQUENCY)-(dfs.dropna()['tempV']-dfs.dropna()['tempV'].min())*FREQVSVOLT- (dfs.dropna()['currV']-dfs.dropna()['currV'].min())*FREQVSCURR)*xscale
dfs=[dfs]
plt.gcf().set_dpi(300)
for df in dfs:
df = df.dropna()
ax.errorbar(freqs,
df['ratio']*yscale,
yerr=df['ratioErr'],
fmt=fmt, mfc=mfc, color='black', ms=ms, **kwargs)
ax.set_ylabel(r'$\mathbf{\frac{V_{ss, cat}}{V_{ss}}} $ ')
ax.set_xlabel(r'$\Delta $ (GHz)', fontdict={'weight':'bold'})
if save_folder:
plt.savefig(os.path.join(save_folder, 'ratio_vs_freq.png'))
return freqs, ax
#return plt.gca(), plt.gcf()
#plt.show()
def plot_spline_fit(ax, x, y, s=1, yerr=None, scolor='black',figsize=(12,5), save_folder=None, title='',alpha=0.5,dpi=200,**kwargs):
from scipy.interpolate import splev, splrep
xnew = np.linspace(min(x), max(x), 3*len(x) )
x = sorted(x)
y = [b for a,b in sorted(zip(x,y), key=lambda pair: pair[0])]
spl = splrep(x, y, s=s)
ynew = splev(xnew, spl)
plt.gcf().set_dpi(dpi)
plt.gcf().set_size_inches(figsize)
if yerr is not None:
ax.errorbar(x, y, yerr=yerr, fmt='o', **kwargs)
else:
ax.plot(x,y, 'o', **kwargs)
ax.plot(xnew, ynew, '-', color=scolor, alpha=alpha)
ax.set_ylabel(r'$\mathbf{\frac{V_{ss, cat}}{V_{ss}}} $ ', labeldict)
ax.set_xlabel(r'$\Delta $ (GHz)', **labeldict)
ax.set_title(title, **titledict)
if save_folder:
plt.savefig(os.path.join(save_folder, 'spline_ratio_vs_freq.png'))
return ax
def plot_polyfit(x_data, y_data, spline_degree):
coefficients = np.polyfit(x_data, y_data, spline_degree)
x_interp = np.linspace(min(x_data), max(x_data), 100)
y_interp = np.polyval(coefficients, x_interp)
plt.scatter(x_data, y_data, label='Original Data')
plt.plot(x_interp, y_interp, label='Polynomial Interpolation (Degree={})'.format(spline_degree))
def collect_plots(source, destination, plot_name):
print(f'Collecting plots from {os.path.basename(source)}')
import shutil
os.makedirs(destination, exist_ok=True)
plot_files = []
for root, dirs, files in os.walk(source):
for file in files:
if file == plot_name:
plot_files.append(os.path.join(root, file))
for i, plot_file in enumerate(plot_files, start=0):
new_filename = f'{i}{plot_name}'
destination_path = os.path.join(destination, new_filename)
shutil.copy(plot_file, destination_path)
def create_GIF(images_folder, image_name):
import imageio
with imageio.get_writer(os.path.join(images_folder, f'{image_name}movie.gif'), mode='I', duration=0.5) as writer:
for filename in os.listdir(images_folder):
if image_name in filename:
image = imageio.imread(os.path.join(images_folder, filename))
writer.append_data(image)
def staircase_fit(data):
def moving_average(arr, window_size):
weights = np.ones(window_size) / window_size
return np.convolve(arr, weights, mode='valid')
convdata1 = moving_average(data, 2)
convdata2 = moving_average(data[10:], 2 )
final = convdata1[:len(convdata2)]-convdata2
# plt.plot(data)
# plt.plot(convdata1)
# plt.plot(convdata2)
# plt.show()
# plt.plot(final)
from scipy.signal import find_peaks
x= final
peaks, _ = find_peaks(x, height=0.1, distance=100)
peaks = np.insert(peaks, 0, 0)
plt.plot(x)
plt.plot(peaks, x[peaks], "x")
plt.plot(np.zeros_like(x), "--", color="gray")
plt.show()
levels = []
plot_arr = []
for i, peak in enumerate(peaks):
if i < len(peaks) - 1:
temp = data[ peaks[i]:peaks[i+1] ]
plot_arr.extend( np.ones_like(temp)*np.mean(temp))
levels.append(np.mean(temp))
plt.plot(data)
plt.plot(np.ravel((plot_arr)))
plt.show()
plt.close()
plt.plot(np.array(levels)[np.where(abs(np.diff(levels))>0.05)[0]], 'o', ms=1)
return levels
if __name__ == '__main__':
run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\testPArun9\16-53-10"
filename = os.path.join(run_path, 'data.csv')
bkfilename = os.path.join(run_path, 'data_oldPD.csv')
settingsname = os.path.join(run_path, 'Settings.txt')
dh1 = MTdataHost(SAMPLE_RATE)
dh1.loadCATdata(fileName=filename, settingsName=settingsname)
#dh1.CATbackgroundData(bkfilename)
dh1.setAllCAT(0.002)
# ---------------------
# Look at Loading rate
# ---------------------
# run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\testPArun9\16-38-18"
# filename = os.path.join(run_path, 'data.csv')
# bkfilename = os.path.join(run_path, 'data_oldPD.csv')
# settingsname = os.path.join(run_path, 'Settings.txt')
# dataHost1 = MTdataHost(SAMPLE_RATE)
# dataHost1.loadCATdata(fileName=filename, settingsName=settingsname)
# #dataHost.CATbackgroundData(bkfilename)
# dataHost1.setAllCAT(0.002)
# run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\testPArun10\21-05-29"
# filename = os.path.join(run_path, 'data.csv')
# bkfilename = os.path.join(run_path, 'data_oldPD.csv')
# settingsname = os.path.join(run_path, 'Settings.txt')
# dataHost2 = MTdataHost(SAMPLE_RATE)
# dataHost2.loadCATdata(fileName=filename, settingsName=settingsname)
# #dataHost.CATbackgroundData(bkfilename)
# dataHost2.setAllCAT(0.002)
File loaded: RFmin = 49 MHz, t_mt = 1.050 s.
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
fig, ax = plt.subplots()
plot_results(ax, df, 384394.4, save_folder=MEASURE_FOLDER)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun8')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
fig, ax = plt.subplots()
plot_results(ax, df, 384394.4, save_folder=MEASURE_FOLDER)
100%|██████████| 53/53 [00:01<00:00, 27.82it/s] 100%|██████████| 55/55 [00:02<00:00, 26.83it/s]
(0 165.800
1 162.804
2 159.808
3 156.812
4 153.816
5 150.820
6 147.824
7 144.828
8 141.832
9 138.836
10 135.840
11 132.844
12 129.848
13 126.852
14 123.856
15 120.860
16 117.864
17 114.868
18 111.872
19 108.876
20 105.880
21 102.884
22 99.888
23 96.892
24 93.896
25 90.900
26 87.904
27 84.908
28 81.912
29 78.916
30 75.920
31 72.924
32 69.928
33 66.932
34 63.936
35 60.940
36 57.944
37 54.948
38 51.952
39 48.956
40 45.960
41 42.964
42 39.968
43 36.972
44 33.976
45 30.980
46 27.984
47 24.988
48 21.992
49 18.996
50 16.000
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
fig, ax = plt.subplots()
plot_results(ax, df, 384394.4)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun8')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
fig, ax = plt.subplots()
plot_results(ax, df, 384394.4)
100%|██████████| 53/53 [00:01<00:00, 27.30it/s] 100%|██████████| 55/55 [00:01<00:00, 29.00it/s]
(0 165.800
1 162.804
2 159.808
3 156.812
4 153.816
5 150.820
6 147.824
7 144.828
8 141.832
9 138.836
10 135.840
11 132.844
12 129.848
13 126.852
14 123.856
15 120.860
16 117.864
17 114.868
18 111.872
19 108.876
20 105.880
21 102.884
22 99.888
23 96.892
24 93.896
25 90.900
26 87.904
27 84.908
28 81.912
29 78.916
30 75.920
31 72.924
32 69.928
33 66.932
34 63.936
35 60.940
36 57.944
37 54.948
38 51.952
39 48.956
40 45.960
41 42.964
42 39.968
43 36.972
44 33.976
45 30.980
46 27.984
47 24.988
48 21.992
49 18.996
50 16.000
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
_, ax = plot_results(ax, df, 384394.4)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun8')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
fig, ax = plt.subplots()
plot_results(ax, df, 384394.4)
100%|██████████| 53/53 [00:01<00:00, 26.89it/s] 100%|██████████| 55/55 [00:01<00:00, 30.83it/s]
(0 165.800
1 162.804
2 159.808
3 156.812
4 153.816
5 150.820
6 147.824
7 144.828
8 141.832
9 138.836
10 135.840
11 132.844
12 129.848
13 126.852
14 123.856
15 120.860
16 117.864
17 114.868
18 111.872
19 108.876
20 105.880
21 102.884
22 99.888
23 96.892
24 93.896
25 90.900
26 87.904
27 84.908
28 81.912
29 78.916
30 75.920
31 72.924
32 69.928
33 66.932
34 63.936
35 60.940
36 57.944
37 54.948
38 51.952
39 48.956
40 45.960
41 42.964
42 39.968
43 36.972
44 33.976
45 30.980
46 27.984
47 24.988
48 21.992
49 18.996
50 16.000
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
<Figure size 1920x1440 with 0 Axes>
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
fig, ax = plt.subplots()
_, ax = plot_results(ax, df, 384394.4)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun8')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
plot_results(ax, df, 384394.4)
100%|██████████| 53/53 [00:02<00:00, 24.71it/s] 100%|██████████| 55/55 [00:01<00:00, 28.63it/s]
(0 165.800
1 162.804
2 159.808
3 156.812
4 153.816
5 150.820
6 147.824
7 144.828
8 141.832
9 138.836
10 135.840
11 132.844
12 129.848
13 126.852
14 123.856
15 120.860
16 117.864
17 114.868
18 111.872
19 108.876
20 105.880
21 102.884
22 99.888
23 96.892
24 93.896
25 90.900
26 87.904
27 84.908
28 81.912
29 78.916
30 75.920
31 72.924
32 69.928
33 66.932
34 63.936
35 60.940
36 57.944
37 54.948
38 51.952
39 48.956
40 45.960
41 42.964
42 39.968
43 36.972
44 33.976
45 30.980
46 27.984
47 24.988
48 21.992
49 18.996
50 16.000
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
fig, ax = plt.subplots()
_, ax = plot_results(ax, df, 384394.4)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun8')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
plot_results(ax, df, 384394.4, mfc='blue')
100%|██████████| 53/53 [00:01<00:00, 31.81it/s] 100%|██████████| 55/55 [00:01<00:00, 32.19it/s]
(0 165.800
1 162.804
2 159.808
3 156.812
4 153.816
5 150.820
6 147.824
7 144.828
8 141.832
9 138.836
10 135.840
11 132.844
12 129.848
13 126.852
14 123.856
15 120.860
16 117.864
17 114.868
18 111.872
19 108.876
20 105.880
21 102.884
22 99.888
23 96.892
24 93.896
25 90.900
26 87.904
27 84.908
28 81.912
29 78.916
30 75.920
31 72.924
32 69.928
33 66.932
34 63.936
35 60.940
36 57.944
37 54.948
38 51.952
39 48.956
40 45.960
41 42.964
42 39.968
43 36.972
44 33.976
45 30.980
46 27.984
47 24.988
48 21.992
49 18.996
50 16.000
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
fig, ax = plt.subplots()
_, ax = plot_results(ax, df, 384394.4)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun7')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
plot_results(ax, df, 384394.4, mfc='blue')
100%|██████████| 53/53 [00:01<00:00, 29.18it/s] 100%|██████████| 54/54 [00:01<00:00, 32.15it/s]
(1 165.800
2 162.804
3 159.808
4 156.812
5 153.816
6 150.820
7 147.824
8 144.828
9 141.832
10 138.836
11 135.840
12 132.844
13 129.848
14 126.852
15 123.856
16 120.860
17 117.864
18 114.868
19 111.872
20 108.876
21 105.880
22 102.884
23 99.888
24 96.892
25 93.896
26 90.900
27 87.904
28 84.908
29 81.912
30 78.916
31 75.920
32 72.924
33 69.928
34 66.932
35 63.936
36 60.940
37 57.944
38 54.948
39 51.952
40 48.956
41 45.960
42 42.964
43 39.968
44 36.972
45 33.976
46 30.980
47 27.984
48 24.988
49 21.992
50 18.996
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
fig, ax = plt.subplots()
_, ax = plot_results(ax, df, 384394.4)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun7')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
plot_results(ax, df, 384394.4, mfc='lightblue')
100%|██████████| 53/53 [00:01<00:00, 28.51it/s] 100%|██████████| 54/54 [00:01<00:00, 31.43it/s]
(1 165.800
2 162.804
3 159.808
4 156.812
5 153.816
6 150.820
7 147.824
8 144.828
9 141.832
10 138.836
11 135.840
12 132.844
13 129.848
14 126.852
15 123.856
16 120.860
17 117.864
18 114.868
19 111.872
20 108.876
21 105.880
22 102.884
23 99.888
24 96.892
25 93.896
26 90.900
27 87.904
28 84.908
29 81.912
30 78.916
31 75.920
32 72.924
33 69.928
34 66.932
35 63.936
36 60.940
37 57.944
38 54.948
39 51.952
40 48.956
41 45.960
42 42.964
43 39.968
44 36.972
45 33.976
46 30.980
47 27.984
48 24.988
49 21.992
50 18.996
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/df['ratio'].max()
fig, ax = plt.subplots()
_, ax = plot_results(ax, df, 384394.4)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun7')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/df['ratio'].max()
plot_results(ax, df, 384394.4, mfc='lightblue')
100%|██████████| 53/53 [00:01<00:00, 30.13it/s] 100%|██████████| 54/54 [00:01<00:00, 32.42it/s]
(1 165.800
2 162.804
3 159.808
4 156.812
5 153.816
6 150.820
7 147.824
8 144.828
9 141.832
10 138.836
11 135.840
12 132.844
13 129.848
14 126.852
15 123.856
16 120.860
17 117.864
18 114.868
19 111.872
20 108.876
21 105.880
22 102.884
23 99.888
24 96.892
25 93.896
26 90.900
27 87.904
28 84.908
29 81.912
30 78.916
31 75.920
32 72.924
33 69.928
34 66.932
35 63.936
36 60.940
37 57.944
38 54.948
39 51.952
40 48.956
41 45.960
42 42.964
43 39.968
44 36.972
45 33.976
46 30.980
47 27.984
48 24.988
49 21.992
50 18.996
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
fig, ax = plt.subplots()
_, ax = plot_results(ax, df, 384394.4)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun7')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
plot_results(ax, df, 384394.4, mfc='lightblue')
100%|██████████| 53/53 [00:01<00:00, 26.92it/s] 100%|██████████| 54/54 [00:01<00:00, 31.91it/s]
(1 165.800
2 162.804
3 159.808
4 156.812
5 153.816
6 150.820
7 147.824
8 144.828
9 141.832
10 138.836
11 135.840
12 132.844
13 129.848
14 126.852
15 123.856
16 120.860
17 117.864
18 114.868
19 111.872
20 108.876
21 105.880
22 102.884
23 99.888
24 96.892
25 93.896
26 90.900
27 87.904
28 84.908
29 81.912
30 78.916
31 75.920
32 72.924
33 69.928
34 66.932
35 63.936
36 60.940
37 57.944
38 54.948
39 51.952
40 48.956
41 45.960
42 42.964
43 39.968
44 36.972
45 33.976
46 30.980
47 27.984
48 24.988
49 21.992
50 18.996
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
fig, ax = plt.subplots()
_, ax = plot_results(ax, df, 384394.4)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun7')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
plot_results(ax, df, 384394.4, mfc='dogderblue')
100%|██████████| 53/53 [00:01<00:00, 27.43it/s] 100%|██████████| 54/54 [00:01<00:00, 28.22it/s]
(1 165.800
2 162.804
3 159.808
4 156.812
5 153.816
6 150.820
7 147.824
8 144.828
9 141.832
10 138.836
11 135.840
12 132.844
13 129.848
14 126.852
15 123.856
16 120.860
17 117.864
18 114.868
19 111.872
20 108.876
21 105.880
22 102.884
23 99.888
24 96.892
25 93.896
26 90.900
27 87.904
28 84.908
29 81.912
30 78.916
31 75.920
32 72.924
33 69.928
34 66.932
35 63.936
36 60.940
37 57.944
38 54.948
39 51.952
40 48.956
41 45.960
42 42.964
43 39.968
44 36.972
45 33.976
46 30.980
47 27.984
48 24.988
49 21.992
50 18.996
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
Error in callback <function _draw_all_if_interactive at 0x000002042176BD80> (for post_execute):
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\pyplot.py:120, in _draw_all_if_interactive() <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/pyplot.py?line=117'>118</a> def _draw_all_if_interactive(): <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/pyplot.py?line=118'>119</a> if matplotlib.is_interactive(): --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/pyplot.py?line=119'>120</a> draw_all() File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\_pylab_helpers.py:132, in Gcf.draw_all(cls, force) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_pylab_helpers.py?line=129'>130</a> for manager in cls.get_all_fig_managers(): <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_pylab_helpers.py?line=130'>131</a> if force or manager.canvas.figure.stale: --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_pylab_helpers.py?line=131'>132</a> manager.canvas.draw_idle() File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\backend_bases.py:2082, in FigureCanvasBase.draw_idle(self, *args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2079'>2080</a> if not self._is_idle_drawing: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2080'>2081</a> with self._idle_draw_cntx(): -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2081'>2082</a> self.draw(*args, **kwargs) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\backends\backend_agg.py:400, in FigureCanvasAgg.draw(self) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backends/backend_agg.py?line=395'>396</a> # Acquire a lock on the shared font cache. <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backends/backend_agg.py?line=396'>397</a> with RendererAgg.lock, \ <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backends/backend_agg.py?line=397'>398</a> (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backends/backend_agg.py?line=398'>399</a> else nullcontext()): --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backends/backend_agg.py?line=399'>400</a> self.figure.draw(self.renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backends/backend_agg.py?line=400'>401</a> # A GUI class may be need to update a window using this draw, so <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backends/backend_agg.py?line=401'>402</a> # don't forget to call the superclass. <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backends/backend_agg.py?line=402'>403</a> super().draw() File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=92'>93</a> @wraps(draw) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=93'>94</a> def draw_wrapper(artist, renderer, *args, **kwargs): ---> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=94'>95</a> result = draw(artist, renderer, *args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=95'>96</a> if renderer._rasterizing: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=96'>97</a> renderer.stop_rasterizing() File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=68'>69</a> if artist.get_agg_filter() is not None: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=69'>70</a> renderer.start_filter() ---> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=71'>72</a> return draw(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=72'>73</a> finally: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=73'>74</a> if artist.get_agg_filter() is not None: File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\figure.py:3140, in Figure.draw(self, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3136'>3137</a> # ValueError can occur when resizing a window. <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3138'>3139</a> self.patch.draw(renderer) -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3139'>3140</a> mimage._draw_list_compositing_images( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3140'>3141</a> renderer, self, artists, self.suppressComposite) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3142'>3143</a> for sfig in self.subfigs: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3143'>3144</a> sfig.draw(renderer) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=128'>129</a> if not_composite or not has_images: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=129'>130</a> for a in artists: --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=130'>131</a> a.draw(renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=131'>132</a> else: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=132'>133</a> # Composite any adjacent images together <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=133'>134</a> image_group = [] File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=68'>69</a> if artist.get_agg_filter() is not None: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=69'>70</a> renderer.start_filter() ---> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=71'>72</a> return draw(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=72'>73</a> finally: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=73'>74</a> if artist.get_agg_filter() is not None: File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_base.py:3064, in _AxesBase.draw(self, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3060'>3061</a> if artists_rasterized: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3061'>3062</a> _draw_rasterized(self.figure, artists_rasterized, renderer) -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3063'>3064</a> mimage._draw_list_compositing_images( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3064'>3065</a> renderer, self, artists, self.figure.suppressComposite) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3066'>3067</a> renderer.close_group('axes') <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3067'>3068</a> self.stale = False File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=128'>129</a> if not_composite or not has_images: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=129'>130</a> for a in artists: --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=130'>131</a> a.draw(renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=131'>132</a> else: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=132'>133</a> # Composite any adjacent images together <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=133'>134</a> image_group = [] File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=68'>69</a> if artist.get_agg_filter() is not None: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=69'>70</a> renderer.start_filter() ---> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=71'>72</a> return draw(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=72'>73</a> finally: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=73'>74</a> if artist.get_agg_filter() is not None: File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\lines.py:810, in Line2D.draw(self, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=805'>806</a> gc.set_antialiased(self._antialiased) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=807'>808</a> ec_rgba = mcolors.to_rgba( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=808'>809</a> self.get_markeredgecolor(), self._alpha) --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=809'>810</a> fc_rgba = mcolors.to_rgba( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=810'>811</a> self._get_markerfacecolor(), self._alpha) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=811'>812</a> fcalt_rgba = mcolors.to_rgba( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=812'>813</a> self._get_markerfacecolor(alt=True), self._alpha) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=813'>814</a> # If the edgecolor is "auto", it is set according to the *line* <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=814'>815</a> # color but inherits the alpha value of the *face* color, if any. File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\colors.py:299, in to_rgba(c, alpha) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=296'>297</a> rgba = None <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=297'>298</a> if rgba is None: # Suppress exception chaining of cache lookup failure. --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=298'>299</a> rgba = _to_rgba_no_colorcycle(c, alpha) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=299'>300</a> try: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=300'>301</a> _colors_full_map.cache[c, alpha] = rgba File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\colors.py:374, in _to_rgba_no_colorcycle(c, alpha) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=369'>370</a> raise ValueError( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=370'>371</a> f"Invalid string grayscale value {orig_c!r}. " <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=371'>372</a> f"Value must be within 0-1 range") <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=372'>373</a> return c, c, c, alpha if alpha is not None else 1. --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=373'>374</a> raise ValueError(f"Invalid RGBA argument: {orig_c!r}") <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=374'>375</a> # turn 2-D array into 1-D array <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=375'>376</a> if isinstance(c, np.ndarray): ValueError: Invalid RGBA argument: 'dogderblue'
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\IPython\core\formatters.py:338, in BaseFormatter.__call__(self, obj) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/IPython/core/formatters.py?line=335'>336</a> pass <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/IPython/core/formatters.py?line=336'>337</a> else: --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/IPython/core/formatters.py?line=337'>338</a> return printer(obj) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/IPython/core/formatters.py?line=338'>339</a> # Finally look for special method names <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/IPython/core/formatters.py?line=339'>340</a> method = get_real_method(obj, self.print_method) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\IPython\core\pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/IPython/core/pylabtools.py?line=148'>149</a> from matplotlib.backend_bases import FigureCanvasBase <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/IPython/core/pylabtools.py?line=149'>150</a> FigureCanvasBase(fig) --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/IPython/core/pylabtools.py?line=151'>152</a> fig.canvas.print_figure(bytes_io, **kw) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/IPython/core/pylabtools.py?line=152'>153</a> data = bytes_io.getvalue() <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/IPython/core/pylabtools.py?line=153'>154</a> if fmt == 'svg': File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\backend_bases.py:2342, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2335'>2336</a> renderer = _get_renderer( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2336'>2337</a> self.figure, <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2337'>2338</a> functools.partial( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2338'>2339</a> print_method, orientation=orientation) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2339'>2340</a> ) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2340'>2341</a> with getattr(renderer, "_draw_disabled", nullcontext)(): -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2341'>2342</a> self.figure.draw(renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2343'>2344</a> if bbox_inches: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/backend_bases.py?line=2344'>2345</a> if bbox_inches == "tight": File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=92'>93</a> @wraps(draw) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=93'>94</a> def draw_wrapper(artist, renderer, *args, **kwargs): ---> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=94'>95</a> result = draw(artist, renderer, *args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=95'>96</a> if renderer._rasterizing: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=96'>97</a> renderer.stop_rasterizing() File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=68'>69</a> if artist.get_agg_filter() is not None: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=69'>70</a> renderer.start_filter() ---> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=71'>72</a> return draw(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=72'>73</a> finally: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=73'>74</a> if artist.get_agg_filter() is not None: File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\figure.py:3140, in Figure.draw(self, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3136'>3137</a> # ValueError can occur when resizing a window. <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3138'>3139</a> self.patch.draw(renderer) -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3139'>3140</a> mimage._draw_list_compositing_images( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3140'>3141</a> renderer, self, artists, self.suppressComposite) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3142'>3143</a> for sfig in self.subfigs: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/figure.py?line=3143'>3144</a> sfig.draw(renderer) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=128'>129</a> if not_composite or not has_images: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=129'>130</a> for a in artists: --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=130'>131</a> a.draw(renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=131'>132</a> else: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=132'>133</a> # Composite any adjacent images together <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=133'>134</a> image_group = [] File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=68'>69</a> if artist.get_agg_filter() is not None: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=69'>70</a> renderer.start_filter() ---> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=71'>72</a> return draw(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=72'>73</a> finally: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=73'>74</a> if artist.get_agg_filter() is not None: File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_base.py:3064, in _AxesBase.draw(self, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3060'>3061</a> if artists_rasterized: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3061'>3062</a> _draw_rasterized(self.figure, artists_rasterized, renderer) -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3063'>3064</a> mimage._draw_list_compositing_images( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3064'>3065</a> renderer, self, artists, self.figure.suppressComposite) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3066'>3067</a> renderer.close_group('axes') <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=3067'>3068</a> self.stale = False File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\image.py:131, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=128'>129</a> if not_composite or not has_images: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=129'>130</a> for a in artists: --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=130'>131</a> a.draw(renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=131'>132</a> else: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=132'>133</a> # Composite any adjacent images together <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/image.py?line=133'>134</a> image_group = [] File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=68'>69</a> if artist.get_agg_filter() is not None: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=69'>70</a> renderer.start_filter() ---> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=71'>72</a> return draw(artist, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=72'>73</a> finally: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=73'>74</a> if artist.get_agg_filter() is not None: File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\lines.py:810, in Line2D.draw(self, renderer) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=805'>806</a> gc.set_antialiased(self._antialiased) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=807'>808</a> ec_rgba = mcolors.to_rgba( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=808'>809</a> self.get_markeredgecolor(), self._alpha) --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=809'>810</a> fc_rgba = mcolors.to_rgba( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=810'>811</a> self._get_markerfacecolor(), self._alpha) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=811'>812</a> fcalt_rgba = mcolors.to_rgba( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=812'>813</a> self._get_markerfacecolor(alt=True), self._alpha) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=813'>814</a> # If the edgecolor is "auto", it is set according to the *line* <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=814'>815</a> # color but inherits the alpha value of the *face* color, if any. File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\colors.py:299, in to_rgba(c, alpha) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=296'>297</a> rgba = None <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=297'>298</a> if rgba is None: # Suppress exception chaining of cache lookup failure. --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=298'>299</a> rgba = _to_rgba_no_colorcycle(c, alpha) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=299'>300</a> try: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=300'>301</a> _colors_full_map.cache[c, alpha] = rgba File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\colors.py:374, in _to_rgba_no_colorcycle(c, alpha) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=369'>370</a> raise ValueError( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=370'>371</a> f"Invalid string grayscale value {orig_c!r}. " <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=371'>372</a> f"Value must be within 0-1 range") <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=372'>373</a> return c, c, c, alpha if alpha is not None else 1. --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=373'>374</a> raise ValueError(f"Invalid RGBA argument: {orig_c!r}") <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=374'>375</a> # turn 2-D array into 1-D array <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/colors.py?line=375'>376</a> if isinstance(c, np.ndarray): ValueError: Invalid RGBA argument: 'dogderblue'
<Figure size 1920x1440 with 1 Axes>
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
fig, ax = plt.subplots()
_, ax = plot_results(ax, df, 384394.4)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun7')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
plot_results(ax, df, 384394.4, mfc='dodgerblue')
100%|██████████| 53/53 [00:01<00:00, 29.59it/s] 100%|██████████| 54/54 [00:01<00:00, 32.39it/s]
(1 165.800
2 162.804
3 159.808
4 156.812
5 153.816
6 150.820
7 147.824
8 144.828
9 141.832
10 138.836
11 135.840
12 132.844
13 129.848
14 126.852
15 123.856
16 120.860
17 117.864
18 114.868
19 111.872
20 108.876
21 105.880
22 102.884
23 99.888
24 96.892
25 93.896
26 90.900
27 87.904
28 84.908
29 81.912
30 78.916
31 75.920
32 72.924
33 69.928
34 66.932
35 63.936
36 60.940
37 57.944
38 54.948
39 51.952
40 48.956
41 45.960
42 42.964
43 39.968
44 36.972
45 33.976
46 30.980
47 27.984
48 24.988
49 21.992
50 18.996
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
fig, ax = plt.subplots()
_, ax = plot_results(ax, df, 384394.4, ms=7)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun7')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
plot_results(ax, df, 384394.4, mfc='dodgerblue', ms=7)
100%|██████████| 53/53 [00:01<00:00, 28.80it/s] 100%|██████████| 54/54 [00:01<00:00, 32.33it/s]
(1 165.800
2 162.804
3 159.808
4 156.812
5 153.816
6 150.820
7 147.824
8 144.828
9 141.832
10 138.836
11 135.840
12 132.844
13 129.848
14 126.852
15 123.856
16 120.860
17 117.864
18 114.868
19 111.872
20 108.876
21 105.880
22 102.884
23 99.888
24 96.892
25 93.896
26 90.900
27 87.904
28 84.908
29 81.912
30 78.916
31 75.920
32 72.924
33 69.928
34 66.932
35 63.936
36 60.940
37 57.944
38 54.948
39 51.952
40 48.956
41 45.960
42 42.964
43 39.968
44 36.972
45 33.976
46 30.980
47 27.984
48 24.988
49 21.992
50 18.996
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
import os
import sys
from functools import partial
sys.path.append(os.path.join(os.getcwd(), '..')) #adds directory below as valid path
from datetime import datetime, timedelta
dateformat = "%H-%M-%S"
from collections import deque
import traceback
from multiprocessing import Pool
from tqdm import tqdm
import scipy.constants as spc
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
plt.rcParams['axes.grid'] = True
plt.rcParams['grid.linestyle'] = '--'
from MT_class_PID_new import MTdataHost
from global_folder.myplotsty import *
PUMP_FREQUENCY = 384228.6
REPUMP_FREQUENCY = 384228.6 + 6.56
SAMPLE_RATE = 2000
FREQVSVOLT = 220.0
FREQVSCURR = 1.16
# TODO: find a better place for this
EXP_FOLDER =r'C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements'
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun10')
WDATA_FOLDER =os.path.join(MEASURE_FOLDER, 'testPArun10.csv')
# TODO: maybe make a run analysis class out of this?
def dump():
plot_results(df, max_freq= 384219., fmt='o', mfc='red', save_folder=MEASURE_FOLDER)
plt.savefig(os.path.join(MEASURE_FOLDER, 'ratio_vs_freq.png'))
collect_plots(MEASURE_FOLDER, os.path.join(MEASURE_FOLDER, 'collected_plots'), 'deloadPhase.png')
#-----------------------
# SINGLE RUN
#-----------------------
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
#freqs = plot_results(df, 384201., save_folder=MEASURE_FOLDER)
data = df.dropna()
freqs = ((384201-PUMP_FREQUENCY)-(data['tempV']-df['tempV'].min())*FREQVSVOLT- (data['currV']-df['currV'].min())*FREQVSCURR)
fig, ax = plt.subplots()
plot_spline_fit(ax=ax, x=freqs, y=data['ratio'], yerr=data['ratioErr'],
s=0.1, save_folder=MEASURE_FOLDER,
mfc='red', color='black',
title='Trap Depth = 1.99 K')
#-----------------------
# MULTIPLE RUN COMPARISON
#-----------------------
folders = [os.path.join(EXP_FOLDER, path ) for path in ['testPARun11', 'testPARun12', 'testPARun13', 'testPARun14']]
dfs = [get_data_frame(measure_folder, cache_all=True) for measure_folder in folders]
colors = ['red', 'dodgerblue', 'green', 'grey']
max_freqs = [384178.881, 384178.593,384179.068, 384184.731]
#max_freqs=[384178.599, 384179.091, 384184.733]
zipped_data = list(zip(dfs, max_freqs))
fig, ax = plt.subplots()
for i, (df, max_freq) in enumerate(zipped_data[:3]):
data = df.dropna()
freqs = ((max_freq-PUMP_FREQUENCY)-(data['tempV']-data['tempV'].min())*FREQVSVOLT- (data['currV']-data['currV'].min())*FREQVSCURR)
color = colors[i]
ax=plot_spline_fit(ax, x=freqs, y=data['ratio'], scolor=color, mfc=color,color=color, s=0.02, ms=5)
#-----------------------
# PARSING WAVEMETER DATA
#-----------------------
FREQVSVOLT = 225.0
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testPArun14')
WDATA_FOLDER =os.path.join(MEASURE_FOLDER, 'testPArun14.csv')
freq_data, max_freq, min_freq = add_wavemeter_data('', WDATA_FOLDER)
data = freq_data[:]
levels = staircase_fit(data)
data = get_data_frame(MEASURE_FOLDER)
data.dropna(inplace=True)
freqs = ((max_freq)-(data['tempV']-data['tempV'].min())*FREQVSVOLT- (data['currV']-data['currV'].min())*FREQVSCURR)
plt.plot(freqs)
# -----------------------
# RELATIVE SCATTERING RATE
# -----------------------
run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\relScatRate\22-09-38"
filename = os.path.join(run_path, 'data.csv')
bkfilename = os.path.join(run_path, 'data_oldPD.csv')
settingsname = os.path.join(run_path, 'Settings.txt')
dh1 = MTdataHost(SAMPLE_RATE)
dh1.loadCATdata(fileName=filename, settingsName=settingsname)
dh1.tBaseline = 1
dh1.tLoad = 2
dh1.timeLoad = 60
dh1.tReload = dh1.tLoad + dh1.timeLoad
dh1.timeReload = 1
dh1.tCATbackground = dh1.tReload + dh1.timeReload
#dh1.CATbackgroundData(bkfilename)
dh1.setAllCAT(0.002)
print(dh1.motSS/(dh1.reloadVolt+dh1.baseVolt - (dh1.CATbackgroundVolt+dh1.noLightBackground)))
plt.scatter(dh1.time, dh1.voltage, s=0.1)
plt.plot(dh1.reloadTime,dh1.reloadFitVoltage, c='orange')
plt.plot(dh1.loadingTime,dh1.motFit, c='red')
plt.plot(dh1.baseTime,dh1.baseVoltage, c='yellow')
plt.plot(dh1.CATbackgroundTime,dh1.CATbackgroundVoltage, c='pink')
def save_fit_results(run_path, plot=False):
filename = os.path.join(run_path, 'data.csv')
bkfilename = os.path.join(run_path, 'data_oldPD.csv')
settingsname = os.path.join(run_path, 'Settings.txt')
dataHost = MTdataHost(SAMPLE_RATE)
dataHost.loadCATdata(fileName=filename, settingsName=settingsname)
dataHost.CATbackgroundData(bkfilename)
dataHost.setAllCAT(0.002)
resultDict = dataHost.getResults(run_path, store=True)
if plot:
dataHost.storeFits(run_path, combined=True, separate=True)
return resultDict, dataHost.settings
def get_timestamp(run_path):
timestamp = datetime.strptime(os.path.split(run_path)[-1].split('_')[0], dateformat)
return timestamp
def extract_fit(run_path, plot=True, cache_failed=True, cache_all=True):
"""Gather relevant data from each measurement run
Args:
run_path : absolute path to the run directory
plot (bool, optional): plot fits. Defaults to True.
cache_failed (bool, optional): Cache failed fits. If false, refit. Doesn't refit non-failed fits. Defaults to True.
cache_all (bool, optional): If false, ignore any cached fit_results. Defaults to True.
Returns:
a 3-tuple (fit_results, settings, timestamp)
"""
fit_results, settings, timestamp = {}, {}, None
if not os.path.isdir(run_path):
return fit_results, settings, timestamp # directory is not a run directory
try:
timestamp = get_timestamp(run_path)
# TODO: specify which error to catch
except Exception as e:
print("Error extracting timestamp from: ", run_path)
print(traceback.format_exc())
MAT_fit_cache_path = os.path.join(run_path, 'resultDict.txt')
if not os.path.exists(MAT_fit_cache_path) or not cache_all:
try:
fit_results, settings = save_fit_results(run_path, plot=plot)
except Exception as e:
print(traceback.format_exc())
print("Fitting ERROR at ", os.path.basename(run_path), '\n')
with open(MAT_fit_cache_path, 'w') as f:
f.write(str('MAT fit failed'))
else:
print("Accessing cached results from :", os.path.basename(run_path))
fit_results = open(MAT_fit_cache_path, 'r').read()
if fit_results == 'MAT fit failed':
if not cache_failed:
# fit regardless of cached result
try:
fit_results = save_fit_results(run_path, plot=plot)
except Exception as e:
print(traceback.format_exc())
print("Fitting ERROR at ", os.path.basename(run_path), '\n')
with open(MAT_fit_cache_path, 'w') as f:
f.write(str('MAT fit failed'))
else:
print("Failed fit at :", os.path.basename(run_path))
fit_results = {}
else:
fit_results = eval(open(MAT_fit_cache_path, 'r').read())
settingsname = os.path.join(run_path, 'Settings.txt')
settings = eval(open(settingsname, 'r').read())
return fit_results, settings, timestamp
def get_row(run_path, **kwargs):
fit_results, settings, timestamp = extract_fit(run_path, **kwargs)
row = {**fit_results, **settings, **{'timestamp':timestamp}}
return row
def get_data_frame(data_dir, parallel=True, in_process_run=False, **kwargs):
run_path_arr = []
rows = []
for relative_path in os.listdir(data_dir):
run_path_arr.append(os.path.join(data_dir, relative_path))
if in_process_run:
run_path_arr.pop()
run_path_arr = sorted(run_path_arr)
if parallel:
with Pool(4) as p:
rows = list(tqdm(p.imap(partial(get_row, **kwargs), run_path_arr), total=len(run_path_arr)))
else:
for run_path in tqdm(run_path_arr):
rows.append(get_row(run_path, **kwargs))
return pd.DataFrame.from_dict(rows)
def add_wavemeter_data(df, wmeter_csv_path, window_size=100, num_rows=50):
"""Extract unique frequnecy values from wavemeter data
Returns:
unique_levels (list): unique frequency values in wavemeter data
"""
# TODO: modify dataframe in place with frequency data
wdata = pd.read_csv(wmeter_csv_path, skiprows=2)
wdata.dropna(inplace=True)
freq_data = np.array(wdata.iloc[:, 0])
try:
freq_data = np.array([float(item) for item in freq_data if item.replace('.','').isdigit()])
except Exception as e:
pass
max_freq = freq_data.max()
min_freq = freq_data.min()
return freq_data, max_freq, min_freq
def plot_results(ax, dfs, max_freq, min_freq=0.0, mfc='red', fmt='o', ms=5, save_folder=False, xscale=1.0, yscale=1.0, **kwargs):
FREQVSVOLT = 214.0
FREQVSCURR = 1.14
if not type(dfs) == list:
freqs = ((max_freq-PUMP_FREQUENCY)-(dfs.dropna()['tempV']-dfs.dropna()['tempV'].min())*FREQVSVOLT- (dfs.dropna()['currV']-dfs.dropna()['currV'].min())*FREQVSCURR)*xscale
dfs=[dfs]
plt.gcf().set_dpi(300)
for df in dfs:
df = df.dropna()
ax.errorbar(freqs,
df['ratio']*yscale,
yerr=df['ratioErr'],
fmt=fmt, mfc=mfc, color='black', ms=ms, **kwargs)
ax.set_ylabel(r'$\mathbf{\frac{V_{ss, cat}}{V_{ss}}} $ ', **labeldict)
ax.set_xlabel(r'$\Delta $ (GHz)', **labeldict)
if save_folder:
plt.savefig(os.path.join(save_folder, 'ratio_vs_freq.png'))
return freqs, ax
#return plt.gca(), plt.gcf()
#plt.show()
def plot_spline_fit(ax, x, y, s=1, yerr=None, scolor='black',figsize=(12,5), save_folder=None, title='',alpha=0.5,dpi=200,**kwargs):
from scipy.interpolate import splev, splrep
xnew = np.linspace(min(x), max(x), 3*len(x) )
x = sorted(x)
y = [b for a,b in sorted(zip(x,y), key=lambda pair: pair[0])]
spl = splrep(x, y, s=s)
ynew = splev(xnew, spl)
plt.gcf().set_dpi(dpi)
plt.gcf().set_size_inches(figsize)
if yerr is not None:
ax.errorbar(x, y, yerr=yerr, fmt='o', **kwargs)
else:
ax.plot(x,y, 'o', **kwargs)
ax.plot(xnew, ynew, '-', color=scolor, alpha=alpha)
ax.set_ylabel(r'$\mathbf{\frac{V_{ss, cat}}{V_{ss}}} $ ', labeldict)
ax.set_xlabel(r'$\Delta $ (GHz)', **labeldict)
ax.set_title(title, **titledict)
if save_folder:
plt.savefig(os.path.join(save_folder, 'spline_ratio_vs_freq.png'))
return ax
def plot_polyfit(x_data, y_data, spline_degree):
coefficients = np.polyfit(x_data, y_data, spline_degree)
x_interp = np.linspace(min(x_data), max(x_data), 100)
y_interp = np.polyval(coefficients, x_interp)
plt.scatter(x_data, y_data, label='Original Data')
plt.plot(x_interp, y_interp, label='Polynomial Interpolation (Degree={})'.format(spline_degree))
def collect_plots(source, destination, plot_name):
print(f'Collecting plots from {os.path.basename(source)}')
import shutil
os.makedirs(destination, exist_ok=True)
plot_files = []
for root, dirs, files in os.walk(source):
for file in files:
if file == plot_name:
plot_files.append(os.path.join(root, file))
for i, plot_file in enumerate(plot_files, start=0):
new_filename = f'{i}{plot_name}'
destination_path = os.path.join(destination, new_filename)
shutil.copy(plot_file, destination_path)
def create_GIF(images_folder, image_name):
import imageio
with imageio.get_writer(os.path.join(images_folder, f'{image_name}movie.gif'), mode='I', duration=0.5) as writer:
for filename in os.listdir(images_folder):
if image_name in filename:
image = imageio.imread(os.path.join(images_folder, filename))
writer.append_data(image)
def staircase_fit(data):
def moving_average(arr, window_size):
weights = np.ones(window_size) / window_size
return np.convolve(arr, weights, mode='valid')
convdata1 = moving_average(data, 2)
convdata2 = moving_average(data[10:], 2 )
final = convdata1[:len(convdata2)]-convdata2
# plt.plot(data)
# plt.plot(convdata1)
# plt.plot(convdata2)
# plt.show()
# plt.plot(final)
from scipy.signal import find_peaks
x= final
peaks, _ = find_peaks(x, height=0.1, distance=100)
peaks = np.insert(peaks, 0, 0)
plt.plot(x)
plt.plot(peaks, x[peaks], "x")
plt.plot(np.zeros_like(x), "--", color="gray")
plt.show()
levels = []
plot_arr = []
for i, peak in enumerate(peaks):
if i < len(peaks) - 1:
temp = data[ peaks[i]:peaks[i+1] ]
plot_arr.extend( np.ones_like(temp)*np.mean(temp))
levels.append(np.mean(temp))
plt.plot(data)
plt.plot(np.ravel((plot_arr)))
plt.show()
plt.close()
plt.plot(np.array(levels)[np.where(abs(np.diff(levels))>0.05)[0]], 'o', ms=1)
return levels
if __name__ == '__main__':
run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\testPArun9\16-53-10"
filename = os.path.join(run_path, 'data.csv')
bkfilename = os.path.join(run_path, 'data_oldPD.csv')
settingsname = os.path.join(run_path, 'Settings.txt')
dh1 = MTdataHost(SAMPLE_RATE)
dh1.loadCATdata(fileName=filename, settingsName=settingsname)
#dh1.CATbackgroundData(bkfilename)
dh1.setAllCAT(0.002)
# ---------------------
# Look at Loading rate
# ---------------------
# run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\testPArun9\16-38-18"
# filename = os.path.join(run_path, 'data.csv')
# bkfilename = os.path.join(run_path, 'data_oldPD.csv')
# settingsname = os.path.join(run_path, 'Settings.txt')
# dataHost1 = MTdataHost(SAMPLE_RATE)
# dataHost1.loadCATdata(fileName=filename, settingsName=settingsname)
# #dataHost.CATbackgroundData(bkfilename)
# dataHost1.setAllCAT(0.002)
# run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\testPArun10\21-05-29"
# filename = os.path.join(run_path, 'data.csv')
# bkfilename = os.path.join(run_path, 'data_oldPD.csv')
# settingsname = os.path.join(run_path, 'Settings.txt')
# dataHost2 = MTdataHost(SAMPLE_RATE)
# dataHost2.loadCATdata(fileName=filename, settingsName=settingsname)
# #dataHost.CATbackgroundData(bkfilename)
# dataHost2.setAllCAT(0.002)
File loaded: RFmin = 49 MHz, t_mt = 1.050 s.
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
fig, ax = plt.subplots()
_, ax = plot_results(ax, df, 384394.4, ms=7)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun7')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
plot_results(ax, df, 384394.4, mfc='dodgerblue', ms=7)
100%|██████████| 53/53 [00:01<00:00, 26.78it/s] 100%|██████████| 54/54 [00:01<00:00, 27.47it/s]
(1 165.800
2 162.804
3 159.808
4 156.812
5 153.816
6 150.820
7 147.824
8 144.828
9 141.832
10 138.836
11 135.840
12 132.844
13 129.848
14 126.852
15 123.856
16 120.860
17 117.864
18 114.868
19 111.872
20 108.876
21 105.880
22 102.884
23 99.888
24 96.892
25 93.896
26 90.900
27 87.904
28 84.908
29 81.912
30 78.916
31 75.920
32 72.924
33 69.928
34 66.932
35 63.936
36 60.940
37 57.944
38 54.948
39 51.952
40 48.956
41 45.960
42 42.964
43 39.968
44 36.972
45 33.976
46 30.980
47 27.984
48 24.988
49 21.992
50 18.996
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
fig, ax = plt.subplots()
fig.set_size_inches((12,5))
_, ax = plot_results(ax, df, 384394.4, ms=7)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun7')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
plot_results(ax, df, 384394.4, mfc='dodgerblue', ms=7)
100%|██████████| 53/53 [00:01<00:00, 31.47it/s] 100%|██████████| 54/54 [00:01<00:00, 30.68it/s]
(1 165.800
2 162.804
3 159.808
4 156.812
5 153.816
6 150.820
7 147.824
8 144.828
9 141.832
10 138.836
11 135.840
12 132.844
13 129.848
14 126.852
15 123.856
16 120.860
17 117.864
18 114.868
19 111.872
20 108.876
21 105.880
22 102.884
23 99.888
24 96.892
25 93.896
26 90.900
27 87.904
28 84.908
29 81.912
30 78.916
31 75.920
32 72.924
33 69.928
34 66.932
35 63.936
36 60.940
37 57.944
38 54.948
39 51.952
40 48.956
41 45.960
42 42.964
43 39.968
44 36.972
45 33.976
46 30.980
47 27.984
48 24.988
49 21.992
50 18.996
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun9')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
fig, ax = plt.subplots()
fig.set_size_inches((12,6.5))
_, ax = plot_results(ax, df, 384394.4, ms=7)
MEASURE_FOLDER = os.path.join(EXP_FOLDER, 'testCATrun7')
df = get_data_frame(MEASURE_FOLDER)
# df.drop(['CATbkBool',
# 'CATnoLightBackground', 'CATbkAvg', 'CATprop', 'reloadStartInd',
# 'reloadEndInd'], axis=1,inplace=True)
df.dropna(inplace=True)
df['ratio'] = df['ratio']/(df['ratio'].max()+np.random.normal(0,1,1)*0.05)
plot_results(ax, df, 384394.4, mfc='dodgerblue', ms=7)
100%|██████████| 53/53 [00:01<00:00, 29.61it/s] 100%|██████████| 54/54 [00:01<00:00, 33.57it/s]
(1 165.800
2 162.804
3 159.808
4 156.812
5 153.816
6 150.820
7 147.824
8 144.828
9 141.832
10 138.836
11 135.840
12 132.844
13 129.848
14 126.852
15 123.856
16 120.860
17 117.864
18 114.868
19 111.872
20 108.876
21 105.880
22 102.884
23 99.888
24 96.892
25 93.896
26 90.900
27 87.904
28 84.908
29 81.912
30 78.916
31 75.920
32 72.924
33 69.928
34 66.932
35 63.936
36 60.940
37 57.944
38 54.948
39 51.952
40 48.956
41 45.960
42 42.964
43 39.968
44 36.972
45 33.976
46 30.980
47 27.984
48 24.988
49 21.992
50 18.996
dtype: float64,
<Axes: xlabel='$\\Delta $ (GHz)', ylabel='$\\mathbf{\\frac{V_{ss, cat}}{V_{ss}}} $ '>)
run_path = r"C:\Users\svars\OneDrive\Desktop\UBC Lab\CATExperiment\CATMeasurements\relScatRate\22-22-45"
filename = os.path.join(run_path, 'data.csv')
bkfilename = os.path.join(run_path, 'data_oldPD.csv')
settingsname = os.path.join(run_path, 'Settings.txt')
dh1 = MTdataHost(SAMPLE_RATE)
dh1.loadCATdata(fileName=filename, settingsName=settingsname)
#dh1.CATbackgroundData(bkfilename)
plt.plot(dh1.voltage)
[<matplotlib.lines.Line2D at 0x2043d67a090>]
plt.plot(dh1.voltage[4000:])
[<matplotlib.lines.Line2D at 0x2043d2bffd0>]
plt.plot(dh1.voltage[4000:-100])
[<matplotlib.lines.Line2D at 0x2043d627190>]
plt.plot(dh1.voltage[4000:-200])
[<matplotlib.lines.Line2D at 0x2043df38a50>]
plt.plot(dh1.voltage[4000:-500])
[<matplotlib.lines.Line2D at 0x2043dec7710>]
plt.plot(dh1.voltage[4000:-500], fmt='o', ms=1)
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[40], line 1 ----> 1 plt.plot(dh1.voltage[4000:-500], fmt='o', ms=1) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\pyplot.py:2812, in plot(scalex, scaley, data, *args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/pyplot.py?line=2809'>2810</a> @_copy_docstring_and_deprecators(Axes.plot) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/pyplot.py?line=2810'>2811</a> def plot(*args, scalex=True, scaley=True, data=None, **kwargs): -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/pyplot.py?line=2811'>2812</a> return gca().plot( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/pyplot.py?line=2812'>2813</a> *args, scalex=scalex, scaley=scaley, <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/pyplot.py?line=2813'>2814</a> **({"data": data} if data is not None else {}), **kwargs) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_axes.py:1688, in Axes.plot(self, scalex, scaley, data, *args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=1444'>1445</a> """ <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=1445'>1446</a> Plot y versus x as lines and/or markers. <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=1446'>1447</a> (...) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=1684'>1685</a> (``'green'``) or hex strings (``'#008000'``). <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=1685'>1686</a> """ <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=1686'>1687</a> kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D) -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=1687'>1688</a> lines = [*self._get_lines(*args, data=data, **kwargs)] <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=1688'>1689</a> for line in lines: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_axes.py?line=1689'>1690</a> self.add_line(line) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_base.py:311, in _process_plot_var_args.__call__(self, data, *args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=308'>309</a> this += args[0], <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=309'>310</a> args = args[1:] --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=310'>311</a> yield from self._plot_args( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=311'>312</a> this, kwargs, ambiguous_fmt_datakey=ambiguous_fmt_datakey) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_base.py:544, in _process_plot_var_args._plot_args(self, tup, kwargs, return_kwargs, ambiguous_fmt_datakey) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=541'>542</a> return list(result) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=542'>543</a> else: --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=543'>544</a> return [l[0] for l in result] File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_base.py:544, in <listcomp>(.0) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=541'>542</a> return list(result) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=542'>543</a> else: --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=543'>544</a> return [l[0] for l in result] File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_base.py:537, in <genexpr>(.0) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=533'>534</a> else: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=534'>535</a> labels = [label] * n_datasets --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=536'>537</a> result = (make_artist(x[:, j % ncx], y[:, j % ncy], kw, <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=537'>538</a> {**kwargs, 'label': label}) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=538'>539</a> for j, label in enumerate(labels)) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=540'>541</a> if return_kwargs: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=541'>542</a> return list(result) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\axes\_base.py:351, in _process_plot_var_args._makeline(self, x, y, kw, kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=348'>349</a> default_dict = self._getdefaults(set(), kw) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=349'>350</a> self._setdefaults(default_dict, kw) --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=350'>351</a> seg = mlines.Line2D(x, y, **kw) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/axes/_base.py?line=351'>352</a> return seg, kw File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\_api\deprecation.py:454, in make_keyword_only.<locals>.wrapper(*args, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=447'>448</a> if len(args) > name_idx: <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=448'>449</a> warn_deprecated( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=449'>450</a> since, message="Passing the %(name)s %(obj_type)s " <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=450'>451</a> "positionally is deprecated since Matplotlib %(since)s; the " <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=451'>452</a> "parameter will become keyword-only %(removal)s.", <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=452'>453</a> name=name, obj_type=f"parameter of {func.__name__}()") --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/_api/deprecation.py?line=453'>454</a> return func(*args, **kwargs) File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\lines.py:393, in Line2D.__init__(self, xdata, ydata, linewidth, linestyle, color, gapcolor, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor, markerfacecoloralt, fillstyle, antialiased, dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, pickradius, drawstyle, markevery, **kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=388'>389</a> self.set_markeredgewidth(markeredgewidth) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=390'>391</a> # update kwargs before updating data to give the caller a <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=391'>392</a> # chance to init axes (and hence unit support) --> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=392'>393</a> self._internal_update(kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=393'>394</a> self._pickradius = pickradius <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/lines.py?line=394'>395</a> self.ind_offset = 0 File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:1223, in Artist._internal_update(self, kwargs) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1215'>1216</a> def _internal_update(self, kwargs): <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1216'>1217</a> """ <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1217'>1218</a> Update artist properties without prenormalizing them, but generating <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1218'>1219</a> errors as if calling `set`. <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1219'>1220</a> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1220'>1221</a> The lack of prenormalization is to maintain backcompatibility. <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1221'>1222</a> """ -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1222'>1223</a> return self._update_props( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1223'>1224</a> kwargs, "{cls.__name__}.set() got an unexpected keyword argument " <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1224'>1225</a> "{prop_name!r}") File c:\ProgramData\Anaconda3\envs\magpy_env\Lib\site-packages\matplotlib\artist.py:1197, in Artist._update_props(self, props, errfmt) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1194'>1195</a> func = getattr(self, f"set_{k}", None) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1195'>1196</a> if not callable(func): -> <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1196'>1197</a> raise AttributeError( <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1197'>1198</a> errfmt.format(cls=type(self), prop_name=k)) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1198'>1199</a> ret.append(func(v)) <a href='file:///c%3A/ProgramData/Anaconda3/envs/magpy_env/Lib/site-packages/matplotlib/artist.py?line=1199'>1200</a> if ret: AttributeError: Line2D.set() got an unexpected keyword argument 'fmt'
plt.plot(dh1.voltage[4000:-500], 'o', ms=1)
[<matplotlib.lines.Line2D at 0x2042972bb50>]
plt.plot(dh1.voltage[4000:-500], 'o', ms=2)
[<matplotlib.lines.Line2D at 0x2043e2a58d0>]
plt.plot(dh1.voltage[4000:-500], 'o', ms=1)
[<matplotlib.lines.Line2D at 0x2042d2d29d0>]
folders = [os.path.join(EXP_FOLDER, path ) for path in ['testPARun11', 'testPARun12', 'testPARun13', 'testPARun14']]
dfs = [get_data_frame(measure_folder, cache_all=True) for measure_folder in folders]
colors = ['red', 'dodgerblue', 'green', 'grey']
max_freqs = [384178.881, 384178.593,384179.068, 384184.731]
#max_freqs=[384178.599, 384179.091, 384184.733]
zipped_data = list(zip(dfs, max_freqs))
fig, ax = plt.subplots()
for i, (df, max_freq) in enumerate(zipped_data[:3]):
data = df.dropna()
freqs = ((max_freq-PUMP_FREQUENCY)-(data['tempV']-data['tempV'].min())*FREQVSVOLT- (data['currV']-data['currV'].min())*FREQVSCURR)
color = colors[i]
ax=plot_spline_fit(ax, x=freqs, y=data['ratio'], scolor=color, mfc=color,color=color, s=0.02, ms=5)
0%| | 0/65 [00:00<?, ?it/s]
Restarting magpy_env (Python 3.11.0)...